<%--
  Created by IntelliJ IDEA.
  User: 李昭富
  Date: 2024/5/31
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<%@ page import = "java.sql.*" %>
<%@ include file = "jdbc.jsp" %>
<%
    //1、获得连接
    Connection conn=getConnection();
//2、建立Statement对象
    Statement stmt=conn.createStatement();
//3、生成sql
    int id=Integer.parseInt(request.getParameter("id"));
    String sql="select * from user where id=" + id;
//4、执行Sql
    ResultSet rs=stmt.executeQuery(sql);
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>
<body>
<%if(rs.next()){
    int uid=rs.getInt("id");
    String username=rs.getString("username");
    String nickname=rs.getString("nickname");
    int sex=rs.getInt("sex");
    String str_sex=(sex==1)?"男":"女";
%>
<form action="update.jsp" method="post">
    <p>用户名：<%=username %></p>
    <p>昵称：<input type="text" name="nickname" value="<%=nickname %>" /></p>
    <p>性别：
        <label><input type="radio" name="sex" value="1" <%=sex==1?"checked":"" %> />男</label>
        <label><input type="radio" name="sex" value="0" <%=sex==0?"checked":"" %> />女</label>
    </p>
    <p>
        <input type="hidden" name="id" value="<%=uid %>" />
        <button type="submit">修改</button>
    </p>
</form>
<%}else{ %>
<p>没有找到指定用户</p>
<%} %>
</body>
</html>
